import $http from '../../../servers/http';
import { Result } from '../../schema/Result';
/* 系统配置-号码组管理
---------------------------------------------------------------- */
import {
  NumGroupInfo,
  NumGroupDetail,
  AddNumGroupRequest,
  NumGroupUploadResponse,
  NumGroupUploadRecordDetail,
} from '../../schema/NumGroup';
/**新增号码组 */
export const createNumGroup = (data: AddNumGroupRequest): Promise<any> => {
  return $http.post({
    url: '/icms/callgroupmanager/callgroups',
    data,
  });
};

/**删除号码组 */
export const deleteNumGroup = (id: number): Promise<Result<null>> => {
  return $http.delete({
    url: `/icms/callgroupmanager/callgroups/${id}`,
  });
};

/**查询号码组列表 */
export const getNumGroupList = (data: {
  pageSize: number;
  pageNo: number;
  callGroupName?: string;
  beginTime?: string;
  endTime?: string;
}): Promise<Result<NumGroupInfo[]>> => {
  return $http.get({
    url: '/icms/callgroupmanager/callgroups',
    data,
  });
};

/**查询号码组详情分页 */
export const getNumGroupDetail = (data: {
  pageSize: number;
  pageNo: number;
  callGroupId: number;
}): Promise<Result<NumGroupDetail>> => {
  return $http.get({
    url: `/icms/callgroupmanager/callgroups/info`,
    data,
  });
};

/**流程调试-查询号码组详情分页-号码未加密 */
export const getCallGroupDetail = (data: {
  pageSize: number;
  pageNo: number;
  callGroupId: number;
}): Promise<Result<NumGroupDetail>> => {
  return $http.get({
    url: `/icms/callgroupmanager/callgroups/info/callNumbers`,
    data,
  });
};
/**上传号码到号码组 */
export const uploadNumGroup = (id: number, data: any): Promise<Result<NumGroupUploadResponse>> => {
  return $http.post(
    {
      url: `/icms/callgroupmanager/callgroups/templateupload/${id}`,
      data,
    },
    { timeout: 300000 }
  );
};

/**查询号码组导入记录 */
export const getNumGroupUploadRecord = (
  id: number,
  data: {
    pageSize: number;
    pageNo: number;
  }
): Promise<Result<NumGroupUploadRecordDetail[]>> => {
  return $http.get({
    url: `/icms/callgroupmanager/callgroups/upload/records/${id}`,
    data,
  });
};
